﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter07
{
    using System.IO;

    partial class Program
    {
        internal static void Begin(Action action, bool active = false)
        {
            if (active)
            {
                Console.WriteLine("开始演示：");
                action();
                Console.WriteLine("演示完毕：");
                Console.ReadLine();
            }
        }

        internal static void C01()
        {
            Console.WriteLine("Max entries supported in list: " + SomeLibraryType.MaxEntriesInListC);
        }

        private sealed class SomeLibraryType
        {
            internal const int MaxEntriesInListC = 50;
            internal static readonly int MaxEntriesInList = 50;
        }

        private sealed class SomeType
        {
            internal static readonly Random r = new Random();
            private static int numberOfWrites = 0;
            internal readonly string pathname = "Untitled";
            private FileStream mfs;

            internal SomeType(string pathname)
            {
                this.pathname = pathname;
                mfs = new FileStream(pathname, FileMode.Open);
            }


            internal string DoSomething()
            {
                numberOfWrites += 1;
                return pathname;
            }
        }

        private sealed class AType
        {
            internal static readonly char[] InvalidChars = new char[] { 'A', 'B', 'C' };
        }

        private sealed class AnotherType
        {
            internal static void M()
            {
                AType.InvalidChars[0] = 'X';
                AType.InvalidChars[1] = 'Y';
                AType.InvalidChars[2] = 'Z';
            }
        }
    }
}
